package codec;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

/**
 * Created by ryan on 15-8-25.
 */
public class FileCodecFactory implements ProtocolCodecFactory {
    private ProtocolEncoder encoder;
    private ProtocolDecoder decoder;

    public FileCodecFactory(boolean client) {
        if (client) {
            encoder = new FileRespondEncoder();
            decoder = new FileRequestDecoder();
        } else {
            encoder = new FileRequestEncoder();
            decoder = new FileRespondDecoder();
        }
    }

    public ProtocolDecoder getDecoder(IoSession ioSession) throws Exception {
        return decoder;
    }

    public ProtocolEncoder getEncoder(IoSession ioSession) throws Exception {
        return encoder;
    }


}
